<!DOCTYPE html> 
<html> 
<head> 
	<meta charset="utf-8" /> 
	<title>The proxy on app server</title> 
</head> 
<body> 
<script type="text/javascript"> 
(function () {
	var ret, loc, pos,
		targetWindow,
		hasOwnProperty, 
		parseQueryString;
 
	hasOwnProperty = function (obj, property) {
		if (Object.prototype.hasOwnProperty) {
			return obj.hasOwnProperty(property);
		}
		return (typeof obj[property] !== "undefined" && obj.constructor.prototype[property] !== obj[property]);
	};
 
	parseQueryString = function (hash) {
		var data = {}, items = hash.split("&"), i, item;
		for (i = 0, j = items.length; i < j; i++) {
			item = items[i].split("=");
			if (item.length === 2 && item[0].length > 0) {
				data[""+decodeURIComponent(item[0])] = decodeURIComponent(item[1]);
			}
		}
		return data;
	};
 
	if (navigator.userAgent.toLowerCase().match(/firefox\/[\d.]+/)) {
		loc = location.href, pos = loc.indexOf('#');
		if (pos < 0) {
			return;
		} else {
			pos = loc.substr(pos+1);
		}
	} else {
		pos = location.hash.substr(1);
	}
 
	ret = parseQueryString(pos);
 
	if ( hasOwnProperty(ret, "target") && hasOwnProperty(ret, "host") ) {
		var PATTERN = /top|parent|frames\[(?:(?:['"][a-zA-Z\d-_%\.]*['"])|\d+)\]/;
		if (!PATTERN.test(ret.target)) {
			return;
		}
 
		try
		{
			targetWindow = eval('(parent.' + ret.target + ')');
		}
		catch (e)
		{
			return;
		}
		
 
		var msg = window.name;
		if (!msg || !targetWindow) {
			return;
		}
 
		try{
			call(targetWindow, msg);
		}
		catch (e) {
			var domain = ret.host.split(":")[0], ds = domain.split("."), flag = false;
			for (var i=0, len=ds.length; i<len-1; i++) {
				try{
					document.domain = ds.join(".");
					targetWindow = eval('(parent.' + ret.target + ')');
					call(targetWindow, msg);
					flag = true;
					break;
				}
				catch (e) {
					ds.shift();
					continue;
				}
			}
			
			if (!flag) {
				throw new Error('illegal host');
			}
		}
		
	}
 
	function call(win, data) {
		var J = win.Jet();
		J && J.event.notifyObservers(win, "crossframe:message", J.json.parse(decodeURIComponent(data)) );
	}
})();
</script> 
</body> 
</html> 